package cn.iocoder.yudao.module.cfs.dal.mysql.company;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.cfs.controller.admin.company.vo.SysCompanyPageReqVO;
import cn.iocoder.yudao.module.cfs.dal.dataobject.company.SysCompanyDO;
import com.baomidou.dynamic.datasource.annotation.DS;
import org.apache.ibatis.annotations.Mapper;

/**
 * sys_company Mapper
 *
 * @author 芋道源码
 */
@Mapper
@DS("chengan")
public interface SysCompanyMapper extends BaseMapperX<SysCompanyDO> {

    default PageResult<SysCompanyDO> selectPage(SysCompanyPageReqVO reqVO) {
        String companyCodeStr = reqVO.getCompanyCode() != null ? reqVO.getCompanyCode().toString() : null;

        return selectPage(reqVO, new LambdaQueryWrapperX<SysCompanyDO>()
                .likeIfPresent(SysCompanyDO::getCompanyCode, companyCodeStr)
                .eqIfPresent(SysCompanyDO::getTreeSort, reqVO.getTreeSort())
                .likeIfPresent(SysCompanyDO::getViewCode, reqVO.getViewCode())
                .likeIfPresent(SysCompanyDO::getCompanyName, reqVO.getCompanyName())
                .likeIfPresent(SysCompanyDO::getFullName, reqVO.getFullName())
                .eqIfPresent(SysCompanyDO::getAreaCode, reqVO.getAreaCode())
                .eqIfPresent(SysCompanyDO::getLocalAreaCode, reqVO.getLocalAreaCode())
                .eqIfPresent(SysCompanyDO::getIndustryType, reqVO.getIndustryType())
                .eqIfPresent(SysCompanyDO::getIndustryDept, reqVO.getIndustryDept())
                .eqIfPresent(SysCompanyDO::getCompanyType, reqVO.getCompanyType())
                .eqIfPresent(SysCompanyDO::getUnitType, reqVO.getUnitType())
                .eqIfPresent(SysCompanyDO::getLng, reqVO.getLng())
                .eqIfPresent(SysCompanyDO::getLat, reqVO.getLat())
                .eqIfPresent(SysCompanyDO::getAppId, reqVO.getAppId())
                .eqIfPresent(SysCompanyDO::getDataId, reqVO.getDataId())
                .eqIfPresent(SysCompanyDO::getProvId, reqVO.getProvId())
                .eqIfPresent(SysCompanyDO::getCityId, reqVO.getCityId())
                .eqIfPresent(SysCompanyDO::getCountyId, reqVO.getCountyId())
                .eqIfPresent(SysCompanyDO::getTownId, reqVO.getTownId())
                .eqIfPresent(SysCompanyDO::getVillageId, reqVO.getVillageId())
                .eqIfPresent(SysCompanyDO::getGridId, reqVO.getGridId())
                .eqIfPresent(SysCompanyDO::getStatus, reqVO.getStatus())
                .eqIfPresent(SysCompanyDO::getCreateUser, reqVO.getCreateUser())
                .eqIfPresent(SysCompanyDO::getUpdateUser, reqVO.getUpdateUser())
                .eqIfPresent(SysCompanyDO::getRemarks, reqVO.getRemarks())
                .likeIfPresent(SysCompanyDO::getProvName, reqVO.getProvName())
                .likeIfPresent(SysCompanyDO::getCityName, reqVO.getCityName())
                .likeIfPresent(SysCompanyDO::getCountyName, reqVO.getCountyName())
                .likeIfPresent(SysCompanyDO::getTownName, reqVO.getTownName())
                .likeIfPresent(SysCompanyDO::getVillageName, reqVO.getVillageName())
                .likeIfPresent(SysCompanyDO::getGridName, reqVO.getGridName())
                .eqIfPresent(SysCompanyDO::getNetworkStatus, reqVO.getNetworkStatus())
                .eqIfPresent(SysCompanyDO::getFireSafePerson, reqVO.getFireSafePerson())
                .eqIfPresent(SysCompanyDO::getFireSafePersonTel, reqVO.getFireSafePersonTel())
                .eqIfPresent(SysCompanyDO::getOrgLicense, reqVO.getOrgLicense())
                .eqIfPresent(SysCompanyDO::getAddress, reqVO.getAddress()));
                //.orderByDesc(SysCompanyDO::getCompanyCode))
    }

}